package com.hfh.main.weight.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hfh.main.common.annotate.JwtToken;
import com.hfh.main.common.resp.Result;
import com.hfh.main.group.entity.GroupDetailEntity;
import com.hfh.main.group.entity.GroupEntity;
import com.hfh.main.weight.entity.ScoreWeightEntity;
import com.hfh.main.weight.mapper.ScoreWeightMapper;
import com.hfh.main.weight.service.ScoreWeightService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/** 分值权重
 */
@Tag(name="分值权重、文件管理")
@RestController
@RequestMapping("/scoreWeightEntity")
public class ScoreWeightController {

    @Autowired
    private ScoreWeightMapper scoreWeightMapper;

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    @JwtToken
    @Operation(summary = "权重展示")
    @PostMapping("/query")
    public Result<?> query() {
        LambdaQueryWrapper<ScoreWeightEntity> queryWrapper = new LambdaQueryWrapper<>();
        ScoreWeightEntity scoreWeightEntity = scoreWeightMapper.selectOne(queryWrapper);
        return Result.success("数据请求成功", scoreWeightEntity);
    }

    @JwtToken
    @Operation(summary = "修改")
    @PostMapping("/update")
    public Result<?> update(@RequestBody @Validated ScoreWeightEntity entity) {
        int i = scoreWeightMapper.updateById(entity);
        return Result.success("修改成功", sdf.format(new Date()));
    }

}
